package com.rc.saas.tenant.vo.log;


import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.rc.saas.tenant.common.base.BaseMongoEntity;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 操作日志
 *
 * @Document 用来表明关联的mongo中的那个collection(类似于表名)
 * @Indexed 为某个字段建立索引
 * @Field 声明属性对应的数据库中的哪个字段
 */
//@Document(collection = "tenant_operate_log_yyyyMM")
public class TenantOperateLog extends BaseMongoEntity {
    @ExcelIgnore
    private String NAME_PREFIX = "tenant_operate_log_";

    @ExcelIgnore
    private String userType;

    @ExcelProperty(value = "IP",index = 1)
    private String ip;

    @ExcelIgnore
    private String url;

    @ExcelIgnore
    private String handlerMethod;

    @ExcelIgnore
    private String requestParams;

    @ExcelProperty(value = "操作人",index = 0)
    private String operator;

    @ExcelProperty(value = "操作时间",index = 8)
    private String createTime;

    @ExcelProperty(value = "操作系统",index = 4)
    private String os;

    @ExcelProperty(value = "浏览器",index = 3)
    private String browser;

    @ExcelProperty(value = "登录地点",index = 2)
    private String loginLocation; //登录地址

    @ExcelIgnore
    private String system; //操作系统

    @ExcelProperty(value = "动作类型",index = 6)
    private String actionType; //动作类型 增删改查

    @ExcelProperty(value = "操作表",index = 7)
    private String tableName; //数据表

    @ExcelProperty(value = "操作模块",index = 5)
    private String tableModule; //数据模块

    public TenantOperateLog(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        this.createTime = sdf.format(date);

        this.collectionName = NAME_PREFIX + yyyyMM.format(date);
    }

    public TenantOperateLog() {
        Date now = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        this.createTime = sdf.format(now);

        this.collectionName = NAME_PREFIX + yyyyMM.format(now);
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getHandlerMethod() {
        return handlerMethod;
    }

    public void setHandlerMethod(String handlerMethod) {
        this.handlerMethod = handlerMethod;
    }

    public String getRequestParams() {
        return requestParams;
    }

    public void setRequestParams(String requestParams) {
        this.requestParams = requestParams;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getOs() {
        return os;
    }

    public void setOs(String os) {
        this.os = os;
    }

    public String getBrowser() {
        return browser;
    }

    public void setBrowser(String browser) {
        this.browser = browser;
    }

    public String getLoginLocation() {
        return loginLocation;
    }

    public void setLoginLocation(String loginLocation) {
        this.loginLocation = loginLocation;
    }

    public String getSystem() {
        return system;
    }

    public void setSystem(String system) {
        this.system = system;
    }

    public String getActionType() {
        return actionType;
    }

    public void setActionType(String actionType) {
        this.actionType = actionType;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getTableModule() {
        return tableModule;
    }

    public void setTableModule(String tableModule) {
        this.tableModule = tableModule;
    }
}